package com.ruoyi.dormitory.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dormitory.mapper.TbMedicalRecordMapper;
import com.ruoyi.dormitory.domain.TbMedicalRecord;
import com.ruoyi.dormitory.service.ITbMedicalRecordService;

/**
 * 看病记录Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-28
 */
@Service
public class TbMedicalRecordServiceImpl implements ITbMedicalRecordService
{
    @Autowired
    private TbMedicalRecordMapper tbMedicalRecordMapper;

    /**
     * 查询看病记录
     *
     * @param id 看病记录主键
     * @return 看病记录
     */
    @Override
    public TbMedicalRecord selectTbMedicalRecordById(String id)
    {
        return tbMedicalRecordMapper.selectTbMedicalRecordById(id);
    }

    /**
     * 查询看病记录列表
     *
     * @param tbMedicalRecord 看病记录
     * @return 看病记录
     */
    @Override
    public List<TbMedicalRecord> selectTbMedicalRecordList(TbMedicalRecord tbMedicalRecord)
    {
        return tbMedicalRecordMapper.selectTbMedicalRecordList(tbMedicalRecord);
    }

    /**
     * 新增看病记录
     *
     * @param tbMedicalRecord 看病记录
     * @return 结果
     */
    @Override
    public int insertTbMedicalRecord(TbMedicalRecord tbMedicalRecord)
    {
//        tbMedicalRecord.setCreateTime(DateUtils.getNowDate());
         tbMedicalRecord.setId(UUID.randomUUID().toString().replaceAll("-",""));
        return tbMedicalRecordMapper.insertTbMedicalRecord(tbMedicalRecord);
    }

    /**
     * 修改看病记录
     *
     * @param tbMedicalRecord 看病记录
     * @return 结果
     */
    @Override
    public int updateTbMedicalRecord(TbMedicalRecord tbMedicalRecord)
    {
        tbMedicalRecord.setUpdateTime(DateUtils.getNowDate());
        return tbMedicalRecordMapper.updateTbMedicalRecord(tbMedicalRecord);
    }

    /**
     * 批量删除看病记录
     *
     * @param ids 需要删除的看病记录主键
     * @return 结果
     */
    @Override
    public int deleteTbMedicalRecordByIds(String[] ids)
    {
        return tbMedicalRecordMapper.deleteTbMedicalRecordByIds(ids);
    }

    /**
     * 删除看病记录信息
     *
     * @param id 看病记录主键
     * @return 结果
     */
    @Override
    public int deleteTbMedicalRecordById(String id)
    {
        return tbMedicalRecordMapper.deleteTbMedicalRecordById(id);
    }
}
